import QtQuick
        import QtQuick.Window
        import QtQuick.Controls

        Rectangle {
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.right: parent.right
        id : rootWindowTitleBar


        width: rootWindow.width
        height: 40

        border.color: "red"
        color: "black"

        Text {
        id: rootWindowTitleBarTitleText
        text: rootWindow.title
        color: "white"
        anchors.verticalCenter: parent.verticalCenter
        }

        // 为窗口标题栏添加鼠标事件
        MouseArea {

        anchors.fill: rootWindowTitleBar
        // 只处理鼠标左键
        acceptedButtons: Qt.LeftButton
        // 接收鼠标按下事件
        onPressed: {

        rootWindow.rootWindowTitleMousePos = Qt.point(mouseX,mouseY)
        rootWindow.isMoveWindow = true
        }

        // 鼠标释放，关闭窗口移动flag
        onReleased: {

        if(mouse.button === Qt.LeftButton){

        rootWindow.isMoveWindow = false
        }
        }

        //
        onMouseXChanged: {

        if(rootWindow.isMoveWindow){

        rootWindow.x += mouseX - rootWindow.rootWindowTitleMousePos.x;
        }
        }
        onMouseYChanged: {

        rootWindow.y += mouseY - rootWindow.rootWindowTitleMousePos.y;
        }
        }


        Button {
        id : pushbtnWindowsClose
        width: 30
        height: 30
        anchors.margins: 5
        anchors.right: rootWindowTitleBar.right
        anchors.topMargin: 5
        anchors.verticalCenter: parent.verticalCenter
        text: "X"
        onClicked: {
        Qt.quit()
        }

        }

        Button {

        id : pushbtnWindowsMaximize
        width: 30
        height: 30
        anchors.margins: 5
        anchors.verticalCenter: parent.verticalCenter
        anchors.right: pushbtnWindowsClose.left
        text: "口"
        onClicked: {
            rootWindow.showMaximized()
        }
        }

        Button {

        id : pushbtnWindowsMinimize
        width: 30
        height: 30
        anchors.margins: 5
        anchors.verticalCenter: parent.verticalCenter
        anchors.right: pushbtnWindowsMaximize.left
        text: "一"
        onClicked: {
             rootWindow.showMinimized()
        }
        }

        }
